package JAVA300.第十章IO;

/**
 * 字节缓冲流--输入
 */

import java.io.*;

public class IO_Study10_Buffered {
    public static void main(String[] args) {
        File file = new File("IOTest01.txt");
        InputStream is = null;

        try {
            is = new BufferedInputStream(new FileInputStream(file));


            byte[] flush = new byte[2];//缓冲容器，三个字符的读 包括期间的空格
            int len;//接受长度
            while ((len = is.read(flush))!= -1){
                //字节数组--》字符串 解码
                String str = new String(flush,0,len);
                System.out.println(str);

            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                if (null!= is){
                    is.close();
                }

            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    }

